package com.itheima.web;

import com.itheima.service.OrderSettingService;
import com.itheima.utils.POIUtils;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/orderSetting")
public class OrderSettingController {

    @Reference
    private OrderSettingService orderSettingService;


    @PostMapping("/importData")
    public boolean importData(@RequestParam("file")MultipartFile multipartFile) throws IOException {
        List<String[]> data = POIUtils.readExcel(multipartFile.getInputStream(), multipartFile.getOriginalFilename());
        return orderSettingService.importData(data);
    }
    @GetMapping("/selectByYearMouth/{year}/{mouth}")
    public Map selectByYearMouth(@PathVariable("year")int year,@PathVariable("mouth") int mouth){
        return orderSettingService.selectByYearMonth(year,mouth);
    }



    @GetMapping("/settingDate/{day}/{num}")
    public  boolean settingDate(@PathVariable("day") String day,@PathVariable("num") int num){
        return orderSettingService.settingDate(day,num);
    }
}
